package com.webdemo02.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBHandler {
	private Connection conn = null;

	DBHandler() {
		try {
			Class.forName("com.mysql.jdbc.Driver");
			String url = "jdbc:mysql://localhost/test_struts";
			String username = "dong";
			String password = "xiaodong";
			conn = DriverManager.getConnection(url, username, password);
		} catch (SQLException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}

	public static DBHandler newInstance() {
		return new DBHandler();
	}

	public Connection getConnection() {
		return conn;
	}
}
